#include "StdAfx.h"
#include "PortRS232.h"

CPortRS232::CPortRS232(void):timeout(INFINITE){
	port_id = 0;
	in_queue = 0;
	out_queue = 0;
	baud_rate = 0;
	data_bit = 0;
	stop_bit = 0;
	parity = 0;
}

CPortRS232::~CPortRS232(void){
	DelObj(m_io);
}

bool CPortRS232::SetIOs(CXMLElement *pItem){
	LPTSTR pName = pItem->GetElementName();
	LPTSTR pValue = pItem->GetValue();
	if(0 != strcmp(pName, "IOs")){
		return false;
	}
	port_id = atoi(pItem->GetFirstChild()->GetValue());//1
	in_queue = atoi(pItem->GetNextChild()->GetValue());//="4096" 
	out_queue = atoi(pItem->GetNextChild()->GetValue());//="4096" 
	baud_rate = atoi(pItem->GetNextChild()->GetValue());//="38000" 
	data_bit = atoi(pItem->GetNextChild()->GetValue());//="8" 
	stop_bit = atoi(pItem->GetNextChild()->GetValue());//="1" 
	parity = atoi(pItem->GetNextChild()->GetValue());//="0" 
	timeout = atoi(pItem->GetNextChild()->GetValue());//="300"
	//
	while(pItem->GetNextChild()){
		m_io.push_back(new CIoInfor(pItem->GetCurrentChild()));
	}
	return true;
}
